var t = getApp();

Page({
    data: {
        currentTime: new Date().getTime(),
        timeData: "",
        rewardFlag: !1,
        details: null,
        activity_id: 0,
        progressRules: [],
        ruleLadder: [],
        stepReward: {},
        basic_info: {},
        isViewedPosterList: !1,
        activityPosterList: [],
        show1: !1
    },
    onLoad: function(e) {
        var a = wx.getStorageSync("yz_basic_info");
        if (this.setData({
            basic_info: a
        }), e.id && this.setData({
            activity_id: e.id
        }), e.scene) {
            var i = [];
            i = decodeURIComponent(e.scene).split("&");
            for (var s = 0; s < i.length; s++) {
                var r;
                "id" == (r = i[s].split("="))[0] && this.setData({
                    activity_id: r[1]
                }), "mid" == r[0] && t._setMid(r[1]);
            }
        }
        e.mid && t._setMid(e.mid), this._getData();
    },
    setStepReward: function(t) {
        var e = t.currentTarget.dataset.item;
        this.setData({
            stepReward: e,
            rewardFlag: !0
        });
    },
    setRewardFlag: function() {
        this.setData({
            rewardFlag: !this.data.rewardFlag
        });
    },
    confirm: function() {
        this.setData({
            show1: !1
        });
    },
    _getData: function() {
        var e = this, a = t.getNetAddresss("plugin.customer-increase.frontend.activity.activityDetail");
        t._postNetWork({
            url: a,
            data: {
                id: this.data.activity_id
            },
            success: function(a) {
                var i = a.data;
                if (1 != i.result) return t.tips(i.msg);
                var s = i.data.poster_list.slice(0, 6);
                i.data.reward_pop_list.list && 0 !== i.data.reward_pop_list.list.length && e.setData({
                    show1: !0
                }), e.setData({
                    reward_pop_list: i.data.reward_pop_list,
                    activityPosterList: s,
                    details: i.data
                }), e.setProgressData(i.data.step_rule);
            }
        });
    },
    loadMore: function() {
        this.setData({
            activityPosterList: this.data.details.poster_list,
            isViewedPosterList: !0
        });
    },
    setProgressData: function(t) {
        var e = this.data.details, a = t.some(function(t) {
            return e.invite_count < t.step_people;
        }), i = JSON.parse(JSON.stringify(t));
        i.unshift({
            step_level: 0,
            step_people: a ? i[0].step_people : 0
        }), this.setData({
            ruleLadder: i
        });
        var s = JSON.parse(JSON.stringify(t)), r = {
            positionLeft: "0%",
            step_people: a ? e.invite_count : 0,
            step_level: 0
        };
        if (s.unshift(r), s.length >= 3) if (e.step == s.length - 1) s = s.slice(-3); else if (0 == e.step) s = s.slice(0, 3); else if (s.length - e.step >= 3) s = s.slice(e.step, 3 + e.step); else if (s.length - e.step <= 2) {
            var n = 3 - (s.length - e.step);
            s = s.slice(e.step - n, e.step - n + 3);
        }
        this.setData({
            progressRules: s
        });
    },
    onReady: function() {},
    onChangeTime: function(t) {
        this.setData({
            timeData: t.detail
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    gotoReward: function() {
        wx.navigateTo({
            url: "/packageF/wxFriendExtend/friendRewardRecord/friendRewardRecord"
        });
    },
    onReachBottom: function() {
        0 == this.data.isViewedPosterList && this.loadMore();
    },
    onShareAppMessage: function() {
        if (!this.data.details) return {};
        var t = {
            title: this.data.details.share_title ? this.data.details.share_title : this.data.details.name,
            path: "/packageF/wxFriendExtend/workWxFriendExtend/workWxFriendExtend?id=" + this.data.details.id
        };
        return this.data.details.share_logo_url && (t.imageUrl = this.data.details.share_logo_url), 
        t;
    }
});